package com.wimcorp.magic.cost;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

import com.wimcorp.magic.cards.PlayingCard;
import com.wimcorp.magic.exception.CostException;
import com.wimcorp.magic.players.Player;
import com.wimcorp.magic.spell.Castable;

@Entity
public abstract class Cost {

	private static long identifierCounter = 1;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Long id;

	@Transient
	private long identifier;

	@Transient
	private Castable castable;
	
	@Transient
	private boolean payed;

	protected Cost(){}
	
	public Cost(Cost cost) {
		this.identifier = identifierCounter++;
		this.castable = cost.getCastable();
	}

	public abstract void payCost() throws CostException;


	public Castable getCastable() {
		return castable;
	}

	public void setCastable(Castable castable) {
		this.castable = castable;
	}

	public abstract Cost clone();

	public Player getPlayer() {
		return castable.getPlayer();
	}

	public boolean isPayed() {
		return payed;
	}

	public void setPayed(boolean payed) {
		this.payed = payed;
	}
	
}
